﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;

namespace WXYW
{
    public partial class AddLogisticCompany : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                LogisiticCompanyService logisiticService = new LogisiticCompanyService();
                logisiticService.AddLogisticCompany(NameTxtBox.Text, RelationTxtBox.Text, Contact1TxtBox.Text,
                    Phone1TxtBox.Text, MobilePhone1TxtBox.Text, Fax1TxtBox.Text, Contact2TxtBox.Text, Phone2TxtBox.Text,
                    MobilePhone2TxtBox.Text, Fax2TxtBox.Text, AddressTxtBox.Text, ContextService.CurrentAccount);
                MsgLbl.Text = "物流公司创建成功。";
                ClearForm();
            }
            catch (Exception ex)
            {
                MsgLbl.Text = string.Format("系统错误:{0}", ex.Message);
                LogUtility.LogUtilityIntance.LogMessgae(string.Format("异常::新建物流公司::{0}", ex.ToString()));
            }
        }

        private void ClearForm()
        {
            NameTxtBox.Text = string.Empty;
            RelationTxtBox.Text = string.Empty;
            Contact1TxtBox.Text = string.Empty;
            Phone1TxtBox.Text = string.Empty;
            MobilePhone1TxtBox.Text = string.Empty;
            Fax1TxtBox.Text = string.Empty;
            Contact2TxtBox.Text = string.Empty;
            Phone2TxtBox.Text = string.Empty;
            MobilePhone2TxtBox.Text = string.Empty;
            Fax2TxtBox.Text = string.Empty;
            AddressTxtBox.Text = string.Empty;
        }
    }
}
